<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/taglib_include.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, target-densitydpi=medium-dpi, initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5, user-scalable=no" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<link href="${ctx}/css/layout.css?ver=${layout_css_version}" rel="stylesheet" type="text/css" />
<style type="text/css">
.b-font {
    width: 90%;
    margin:10pt auto 0px;
}
#s-information {
    height:auto!important;
    height: 120pt;
    min-height:120pt;
}
</style>
<title>${projectTitle }</title>
</head>
<body>
  <header id="main-top">
        <a href="javascript:void(0);" id="back">
          <div id="main-top-left">
            <img src="${ctx}/images/mui_title_back_btn.png" class="img-2">
          </div>
        </a>
    <div id="main-top-title">确认乘客</div>
    <a id="main-top-right" href="javascript:void(0);">
      <img src="${ctx }/images/home_icon.png">
    </a>
  </header>
  <div id="container">
    <div class="f-information">
      <span>班次类型：${cf:schTypeName(orderPaymentInfo.schType) }</span>
      <span> 班次: ${orderPaymentInfo.regBusNo} </span>
      <span> 车型: ${orderPaymentInfo.busTypeName}</span>
    </div>
    <div id="s-information">
      <div id="start-information">
        <span class="b-font">${orderPaymentInfo.startStationName}</span>
      </div>
      <div id="d-information">
        <span id="time-information">${orderPaymentInfo.leaveTime}</span>
        <span id="calendar-information">${orderPaymentInfo.leaveDate}</span>
      </div>
      <div id="arrive-information">
        <span class="b-font">${orderPaymentInfo.arriveStationName}</span>
      </div>
    </div>
    <div class="f-information">
      <span>乘车人</span>
    </div>
    <!-- 来源于常用乘车人页面 -->
   <form action="" method="get" id="form">
      <c:forEach items="${passengerList}" var="passenger" varStatus="status">
         <a href="javascript:void(0);">
          <div id="w-bg">
            <input type="hidden" name="passengId" value="${passenger.passengerId}" id="passenger${status.index}">
            <span>
              <img src="${ctx}/images/icon-4.png" width="33" height="36">
            </span>
            <div class="name">
                 ${passenger.fullname}
              <span class="gender">
                 ${cf:genderTitle(passenger.gender) }
              </span>
            </div>
            <div class="Passengers-type"> ${cf:passengerTypeName(passenger.passengerType)} </div>
            <div class="Document-type">
                 ${cf:identificationTypeName(passenger.identificationType)} 
                 ${cf:hiddenIdentificationNumber(passenger.identificationNumber,passenger.identificationType)}
            </div>
            <div class="Passengers-type-title">乘客类型</div>
            <div class="more-1">
              <img src="${ctx}/images/more-icon.png" width="14" height="25">
            </div>
          </div>
          <input type="hidden" value="${passenger.userId}" id="userId${status.index}" name="passengers[${status.index}].userId">
          <input type="hidden" value="${passenger.passengerId}" id="passengerId${status.index}" name="passengers[${status.index}].passengerId">
          <input type="hidden" value="${passenger.fullname}" id="fullname${status.index}" name="passengers[${status.index}].fullname">
          <input type="hidden" value="${passenger.gender}" id="gender${status.index}" name="passengers[${status.index}].gender">
          <input type="hidden" value="${passenger.mobile}" id="mobile${status.index}" name="passengers[${status.index}].mobile">
          <input type="hidden" value="${passenger.identificationType}" id="identificationType${status.index}" name="passengers[${status.index}].identificationType">
          <input type="hidden" value="${passenger.identificationNumber}" id="identificationNumber${status.index}" name="passengers[${status.index}].identificationNumber">
          <input type="hidden" value="${passenger.passengerType}" id="passengerType${status.index}" name="passengers[${status.index}].passengerType">
        </a>
    </c:forEach>

    <div id="total-price">
      <span>
        <img src="${ctx}/images/price-icon.png" width="32" height="32">
      </span>
      <span id="total-p">
        总价
        <span class="s-font-14-2">￥</span>
        <span>${orderPaymentInfo.totalprices}&nbsp;&nbsp;<span id="totalserviceprice"></span></span>
      </span>
    </div>
      <!-- 隐藏表单 -->
      <input type="hidden" name="schType" value="${orderPaymentInfo.schType}" id="schType">
      <input type="hidden" name="regBusNo" value="${orderPaymentInfo.regBusNo}" id="regBusNo">
      <input type="hidden" name="busTypeName" value="${orderPaymentInfo.busTypeName}" id="busTypeName">
      <input type="hidden" name="startStationName" value="${orderPaymentInfo.startStationName}" id="startStationName">
      <input type="hidden" name="arriveStationName" value="${orderPaymentInfo.arriveStationName}" id="arriveStationName">
      <input type="hidden" name="leaveTime" value="${orderPaymentInfo.leaveTime}" id="leaveTime">
      <input type="hidden" name="leaveDate" value="${orderPaymentInfo.leaveDate}" id="leaveDate">
      <input type="hidden" name="orderId" value="${orderPaymentInfo.orderId}" id="orderId">
      <input type="hidden" name="serviceprice" value="${orderPaymentInfo.serviceprice}" id="serviceprice">
      <input type="hidden" name="totalprices" value="${orderPaymentInfo.totalprices}" id="totalprices">
      <input type="hidden" name="fullTicketNum" value="${orderPaymentInfo.fullTicketNum}" id="fullTicketNum">
      <input type="hidden" name="halfTicketNum" value="${orderPaymentInfo.halfTicketNum}" id="halfTicketNum">
      <input type="hidden" name="freeTicketNum" value="${orderPaymentInfo.freeTicketNum}" id="freeTicketNum">
      <input type="hidden" name="price" value="${orderPaymentInfo.price}" id="price">
      <input type="hidden" name="halfPrice" value="${orderPaymentInfo.halfPrice}" id="halfPrice">
      <input type="hidden" name="passengerIds" id="passengerIds">
      <input type="hidden" name="orderpnr" value="${orderPaymentInfo.orderpnr}" id="orderpnr">
      <input type="hidden" name="startstationId" value="${orderPaymentInfo.startstationId}" id="startstationId">
      <input type="hidden" name="lineTypeId" id="lineTypeId" value="${orderPaymentInfo.lineTypeId}"/>
      <input type="hidden" name="hasPrivilege" id="hasPrivilege" value="${orderPaymentInfo.hasPrivilege}"/>
      <input type="hidden" name="totalPrivilegeAmount" id="totalPrivilegeAmount" value="${orderPaymentInfo.totalPrivilegeAmount}"/>
    </form>
  </div>
  <div id="Nticket-tip-1" style="color:#FF4500;">温馨提示：点击“确定”按钮后乘客将不可更改，在此之前你可以重新选择乘客。</div>
   <div id="big-button">
     <a href="javascript:void(0)"><div id="confirm" class="sumbit-1">确&nbsp;&nbsp;&nbsp;定</div></a>
   </div>
  <%@ include file="/WEB-INF/views/popup_alert.jsp"%>
  <%@ include file="/WEB-INF/views/loading.jsp"%>
  <script type="text/javascript" src="${ctx}/js/jquery.min.js?ver=${jquery_min_version}"></script>
  <!-- mergeTo:${ctx}/js/custom.min.js?ver=${custom_min_version} -->
  <script type="text/javascript" src="${ctx}/js/custom.js?ver=${custom_version}"></script>
  <!-- mergeTo -->
  <script type="text/javascript">
      var payResultURL = '${ctx}/pay/result.do?orderpnr=${orderPaymentInfo.orderpnr}'; //支付结果页面地址
      var gotoURL = '';

     $(function(){
         var passengerIds = '';
         var orderId = $("#orderId").val();
         var userId = "${userId}";
         var appVer = "${appVer}";
         var const_appver_nc = "${constant.appver_nc}";
         var const_appver_ylns = "${constant.appver_ylns}";

         var serviceprice = $("#serviceprice").val();
         var privilegeamount = "${privilege_amount}";//优惠金额
//          if(parseFloat(serviceprice) >= 0){
//              $("#totalserviceprice").html("(包含服务费￥${orderPaymentInfo.serviceprice}"+"<c:if test='${hasPrivilege==true}'>,每张已优惠￥"+privilegeamount+"</c:if>"+")");
//          }else{
//              var serviceprice = -(parseFloat(serviceprice));
//              $("#totalserviceprice").html("(已优惠￥"+serviceprice.toFixed(2)+")");
//          }
         $("#main-top-right").bind("click", function(){
             var link = "${ctx}/trafficline/index.do?ver=${appVer}" + "&startCityId=" + localStorage.startCityId + "&starting=" + localStorage.starting + "&startStationId=" + localStorage.startStationId + "&startStationsDisabled=" + localStorage.startStationsDisabled + "&groupId=" + localStorage.groupId;
             if (appVer == const_appver_nc || appVer == const_appver_ylns) {
                 link = "${ctx}/indexnc/index.do?ver=${appVer}"
             }
             window.location.href = link;
         });

         $("#container").find("a").each(function(i){
               passengerIds += $("#passenger"+i).val() + ',';
               $(this).click(function(){
                  $("#passengerIds").val(passengerIds);
                  $("#form").attr("action","${ctx}/passenger/select.do").submit();
               });
         });
        
        //返回按钮绑定单击事件
        $("#back").bind("click",function(e){
             $("#passengerIds").val(passengerIds);
             $("#form").attr("action","${ctx}/passenger/select.do").submit();
        });
         //确定按钮绑定事件
         $("#confirm").bind("click",function(e){
            if(passengerIds.indexOf(userId) != -1){
                rExp = userId;
                passengerIds = passengerIds.replace(rExp, "");
            }
             $.ajax({
                 type: "POST",
                 url:"${ctx}/bindpassenger/bind.do",
                 data : {
                         orderId:orderId,
                         passengerIds:passengerIds,
                         userId:userId
                        },
                 success : function(data){
                     // 乘客绑定成功
                     if(data.errcode == 0){
                    	 var url = "${ctx}/pay/confirm.do?orderId=" + orderId + "&ptiks=" + data.passengerTicketInfos;
                         window.location.href = url;
                     } else {
                    	 openAlert(data.errmsg);
                     }
                 }
             });
         });
     });
  </script>
</body>
</html>